import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.set_auto_whitebal(False)
sensor.set_auto_gain(False)
sensor.skip_frames(time = 2000)


clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot().lens_corr(1.8)

    w = img.width()//20
    h = img.height()//20
    x = img.width()//2-w//2
    y = img.height()//2-h//2

    sts = img.get_statistics(roi=(x,y,w,h))

    img.draw_rectangle(x, y, w, h, color = (255,255,255), thickness = 1, fill = False)


    print(sts.l_min(),sts.l_max(),sts.a_min(),sts.a_max(),sts.b_min(),sts.b_max())
